In SIMO, an array can contain elements of the following types:
All entries in an array should have the same data type. In some situations, an operator may produce different data types for different entries in an array. Then, they are automatically casted to the type with the highest precedence. The higher the precedence, the higher the precision.
For example, the polynomial r is a complex-double array since complex-double has higher precedence than double. As a result, the real root 4 is stored as a complex number, namely, 4.000 - 0.000i.
p=[1 -2 -6 -8];
r=roots(p)
r =
-1.0000 - 1.0000i
-1.0000 + 1.0000i
4.0000 - 0.0000i
Some operators require inputs of specific types. If necessary, the operands are first casted to the required types before performing the operation. For examples:
0.5 + true gives 1.500.'a' * (1 > 0) gives 97.A is casted to a double array when performing cos(A).Structure array is not a numeric type. It is just a container of data. Hence, type casting does not work for structure arrays.